/*
 * c7_exercise5.cpp
 *
 *  Created on: Sep 2, 2013
 *      Author: cyper.yin
 */

#include <iostream>
long double factorial(int number);

using namespace std;
int main_c7e5(int argc, char **argv) {
	cout << "Enter a number, q to quit:";
	int number;
	while (cin >> number) {
		cout << number << "!=" << factorial(number) << endl;
		cout << "Enter a number, q to quit:";
	}

	return 0;
}

long double factorial(int number){
	if (number < 0) {
		return 0;
	}

	if (number < 2) {
		return 1;
	}

	return number * factorial(number - 1);
}

